﻿using Bids.Core.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.OpenAccess;
using Telerik.OpenAccess.Metadata;
using Telerik.OpenAccess.Metadata.Fluent;

namespace Bids.Core.DomainObjects
{
	/// <summary>
	/// 任务列表
	/// </summary>
	[Serializable]
    public class Discussion : IEntity
	{
        
		/// <summary>
		/// 
		/// </summary>
        public virtual int ID { set;  get; }
		/// <summary>
		/// 
		/// </summary>
        public virtual int UserId {   set;  get;}
		/// <summary>
		/// 
		/// </summary>
        public virtual int TaskId { set; get; }
        ///<summary>
		/// 
		/// </summary>
        public virtual string Content { set; get; }
		
		/// <summary>
		/// 时间
		/// </summary>
        public virtual DateTime CreateTime { set;  get; }
        public virtual Task Task { get; set; }
        public virtual User User { get; set; }


        public static MappingConfiguration<Discussion> CreateConfiguration()
        {
            var threadMapping = new MappingConfiguration<Discussion>();
            threadMapping.MapType(t => new
            {
                t.ID,
                t.TaskId,
                t.Content,
               t.UserId,
                t.CreateTime,

            }).ToTable("Discussions");
            threadMapping.HasProperty(t => t.ID).IsIdentity(KeyGenerator.Autoinc);
            threadMapping.HasAssociation(t => t.User).HasConstraint((t, d) => t.UserId == d.ID);
            threadMapping.HasAssociation(t => t.Task).WithOpposite(d => d.Discussionss).HasConstraint((t, d) => t.TaskId == d.ID);
            return threadMapping;
        }
	}
    
}

